Versions:

  • 2.5.2

StyLua is a Lua code formatter published by JohnnyMorganz, currently available at version 2.5.2, with one version listed in the catalog. Falling within the developer tools and code formatting category, StyLua serves as a deterministic code formatter designed to bring consistency to Lua codebases of varying dialects and sizes. Its primary purpose is to parse Lua source code and print it back out from scratch, enforcing a uniform and predictable code style across an entire project rather than merely adjusting individual lines. The tool supports a broad range of Lua variants, including Lua 5.1, 5.2, 5.3, and 5.4, as well as LuaJIT, Luau, and CfxLua/FiveM Lua, making it applicable to standard Lua development, game scripting environments, embedded systems, and platforms built around specialized Lua dialects. StyLua is built using full-moon, a lossless Lua parser, which enables it to reliably interpret source files and re-emit them in a normalized form. The project takes inspiration from formatters such as prettier, adopting the philosophy that code style decisions should be automated so that development teams can avoid debates over formatting and maintain readable, consistent repositories. In terms of stylistic conventions, StyLua mainly follows the Roblox Lua Style Guide, though it introduces a few deliberate deviations from that reference. Typical use cases include integrating the formatter into editor workflows, continuous integration pipelines, and pre-commit hooks to guarantee that all committed Lua code adheres to the same formatting rules. Because the formatter is deterministic, running it repeatedly on the same input produces the same output, which supports reproducible builds and simplifies code review by eliminating formatting noise from diffs. StyLua is suited to individual developers, open-source projects, and teams seeking automated, opinionated formatting for any of the supported Lua dialects.

Tags: